package edu.westga.sketchit2009cs.tester;

import static org.junit.Assert.*;
import edu.westga.sketchit2009cs.players.Player;
import org.junit.Before;
import org.junit.Test;

/**
 * Tests the Player class which is responsible for
 * creating players.
 * @author RJ Hill
 *
 */
public class PlayerTester {
	private Player thePlayer;
	private String playerName = "Johnny";
	private String playerIP = "127.0.0.1";
	private int playerScore = 0;
	private boolean isDrawing = true;
	
	@Before
	public void SetUp() {
		this.thePlayer = new Player(this.playerName, this.playerIP, this.playerScore, this.isDrawing);
	}

	@Test
	public void shouldBeJohnnyWhenGetDefaultName() {
		assertEquals(this.thePlayer.getName(), this.playerName);
	}
	
	@Test
	public void shouldBePhilWhenSetNameToPhil() {
		String newName = "Phil";
		this.thePlayer.setName(newName);
		assertEquals(this.thePlayer.getName(), newName);
	}
	
	@Test
	public void shouldHaveOldNameJohnnyWhenSetNameToPhil() {
		String newName = "Phil";
		this.thePlayer.setName(newName);
		assertEquals(this.thePlayer.getOldName(), playerName);
	}

	@Test
	public void shouldBe127001WhenGetDefaultIP() {
		assertEquals(this.thePlayer.getIP(), this.playerIP);
	}

	@Test
	public void shouldBeZeroWhenGetDefaultScore() {
		assertEquals(this.thePlayer.getScore(), this.playerScore);
	}

	@Test
	public void shouldBeTenWhenSetScoreToTen() {
		int newScore = 10;
		this.thePlayer.setScore(newScore);
		assertEquals(this.thePlayer.getScore(), newScore);
	}

	@Test
	public void shouldBeElevenWhenSetScoreToTenAndIncrementScoreByOne() {
		int newScore = 10;
		int increment = 1;
		this.thePlayer.setScore(newScore);
		this.thePlayer.incrementScore(increment);
		assertEquals(this.thePlayer.getScore(), newScore + increment);
	}

	@Test
	public void shouldBeTrueWhenGetDefaultDrawingPriveleges() {
		assertEquals(this.thePlayer.getDrawingPriveleges(), this.isDrawing);
	}

	@Test
	public void shouldBeFalseWhenSetDrawingPrivelegesToFalse() {
		boolean privileges = false;
		this.thePlayer.setDrawingPriveleges(privileges);
		assertEquals(this.thePlayer.getDrawingPriveleges(), privileges);
	}

}
